<?php
/**
 * 资质-营业执照审核
 * Created by PhpStorm.
 * User: 50223
 * Date: 18.8.7
 * Time: 17:08
 */
namespace App\Http\Controllers\Aptitude;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Session;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\DB;
class CancelController extends Controller
{
    public function cancel (Request $request){

//            审核系统中只查询审核通过的
        $licenseList =  DB::table('cust_material') ->orderBy('id','desc')->where('dcs_card_status','=',2)->paginate(20);

//            获取所有的历史记录 type=1
        $historyAll = DB::table('history')->where('type','=',9)->orderBy('id','desc')->paginate(200);


        return view('aptitude/cancel',[
            'licenseList'=>$licenseList,
            'historyAll'=>$historyAll
        ]);

    }


    public function cust_id_screen(Request $request){

        if($request->isMethod('POST')){
            $cust_id = trim($_POST['cust_id']);
            $dataList = DB::table('cust_material')->where('cust_id','=',$cust_id)->where('dcs_card_status','=',2)->paginate(20);
            if($dataList->count() !=0){
                return array('status'=>1,'msg'=>'共查询到'.$dataList->count().'条结果','dataList'=>$dataList);
            }else{
                return array('status'=>0,'msg'=>'很抱歉,未查询到匹配数据','userinfo'=>'');

            }

        }else{

            return array('status'=>0,'msg'=>'操作失败');exit;
        }
    }

    public function cust_name_screen(Request $request){
        if($request->isMethod('POST')){
            $cust_name = trim($_POST['cust_name']);
            $dataList = DB::table('cust_material')->where('cust_name','=',$cust_name)->where('dcs_card_status','=',2)->paginate(20);
            if($dataList->count() !=0){
                return array('status'=>1,'msg'=>'共查询到'.$dataList->count().'条结果','dataList'=>$dataList);
            }else{
                return array('status'=>0,'msg'=>'很抱歉,未查询到匹配数据','userinfo'=>'');

            }

        }else{

            return array('status'=>0,'msg'=>'操作失败');exit;
        }
    }


    public function time_screen(Request $request){
        if($request->isMethod('POST')){
            $beginTime = strtotime(trim($_POST['beginTime']));
            $endTime = strtotime(trim($_POST['endTime']));

            $dataList = DB::table('cust_material')->whereBetween('dcs_validity',[$beginTime,$endTime])->orWhere('dcs_validity','=',1)->where('dcs_card_status','=',2)  ->paginate(20);
            if($dataList->count() !=0){
                return array('status'=>1,'msg'=>'共查询到'.$dataList->count().'条结果','dataList'=>$dataList);
            }else{
                return array('status'=>0,'msg'=>'很抱歉,未查询到匹配数据','userinfo'=>'');

            }

        }else{

            return array('status'=>0,'msg'=>'操作失败');exit;
        }
    }




}